<%--
  Created by IntelliJ IDEA.
  User: wzs
  Date: 2017/7/15
  Time: 20:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>${title}</title>
    <link href="/css/site.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/js/jquery-1.10.2.js"></script>
</head>
<body>
<div class="container">
    <form id="frmAdd" action="/user/add/submit" method="post">
        <table>
            <tr>
                <td>用户名：</td>
                <td><input name="username" type="text" value=""/></td>
            </tr>
            <tr>
                <td>昵称：</td>
                <td><input name="nickname" type="text" value=""></td>
            </tr>
            <tr>
                <td>密码：</td>
                <td><input name="pwd" type="password" value=""/></td>
            </tr>
            <tr>
                <td>确认密码：</td>
                <td><input name="confirm_pwd" type="password" value=""></td>
            </tr>
            <tr>
                <td>年龄：</td>
                <td><input name="age" type="text" value=""></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input name="email" type="text" value=""></td>
            </tr>
            <tr>
                <td>QQ:</td>
                <td><input name="qq" type="text" value=""></td>
            </tr>
            <tr>
                <td>微信:</td>
                <td><input name="wx" type="text" value=""></td>
            </tr>
            <tr>
                <td><input type="button" id="btnAdd" value="提交"></td>
            </tr>
        </table>
    </form>

</div>

<script>
    $(function () {
        $("#btnAdd").click(function () {
            // 判断密码是否相同
            var pwd = $("input[name=pwd]").val();
            var confirm_pwd = $("input[name=confirm_pwd]").val();
            if (pwd == "" || confirm_pwd == "") {
                alert("密码不能为空！");
                return;
            }
            if (pwd != confirm_pwd) {
                alert("两次输入密码不一致！");
                return;
            }
            var param = $("#frmAdd").serialize();
//            $.post($("#frmAdd").attr("action"), param, function (data, status) {
//                if (data.status == 200) {
//                    alert(data.msg);
//                }
//                else{
//                    alert("新增失败！");
//                }
//
//            })
            $("#frmAdd").submit();
        });
    })
</script>
</body>
</html>
